package com.tsite.common.report;

import java.io.ByteArrayOutputStream;

public class ReportEngine {
	private static ReportEngine instance;
	
	private ReportEngineAbstract reportEngineAbs;
	
	private ReportEngine(){
		reportEngineAbs = new PdfReportEngine();
		XlsReportEngine xlsReportEngine = new XlsReportEngine();
		
		reportEngineAbs.setSuccessor(xlsReportEngine);
	}
	
	public static ReportEngine getInstance(){
		if(instance == null){
			instance = new ReportEngine();
			
		}
		return instance;
	}
	
	public <T> ByteArrayOutputStream generate(ReportRequest<T> reportRequest) throws Exception
	{
		return reportEngineAbs.export(reportRequest);
	}
}
